using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SIOGDE.AccesoDatos.Entidades;
using SIOGDE.Negocios;
using SIOGDE.Negocios.Servicios;
using Didsoft.Mvc.DataModel;
using Didsoft.Mvc.Controller;

namespace SIOGDE.Web.Controllers
{
    public class HistorialAscensoController : BaseController<HistorialAscenso>
    {
	    #region interface servicios HistorialAscenso

		private IHistorialAscensoNegociosServicio servicio = BusinessFactory.Current.GetHistorialAscensoNegocios();

		#endregion
		
		
		#region constructor and overridable

        public HistorialAscensoController()
        {		    
            base.SetDataModelService(servicio);            
        }
		        

		

		#endregion

		#region	actions

		[HttpGet]
		public override ActionResult Index()
        {
            return RedirectToAction("FilterList");
        }


       


        public JsonResult GetPorPersonaGuid(string guid)
        {
            try
            {
                List<HistorialAscenso> items = servicio.GetPorPersonaGuid(guid);
                return Json(new { Result = "OK", Records = items });
            }
            catch (Exception ex)
            {
                return Json(new { Result = "ERROR", Message = ex.Message });
            }

        }

        [HttpPost]
        public JsonResult JSONPagedListByPersona(int personaId = 0, int jtStartIndex = 0, int jtPageSize = 0, string jtSorting = null)
        {
            try
            {
                List<HistorialAscenso> searchedItems = servicio.GetPorPersonaId(personaId);
                var items = searchedItems.Skip(jtStartIndex).Take(jtPageSize).ToList();
                return Json(new { Result = "OK", Records = items, TotalRecordCount = searchedItems.Count() });
            }
            catch (Exception ex)
            {
                return Json(new { Result = "ERROR", Message = ex.Message });
            }
        }

        public ActionResult FormAscensoPersona(string personGuid, string redireccion = "")
        {
            HistorialAscenso historial = new HistorialAscenso();
            historial.Persona = BusinessFactory.Current.GetPersonaNegocios().GetByGuid(personGuid);
            historial.FechaAscenso = new DateTime(2000, 01, 01);
            historial.Descripcion = "Asignado Desde Ficha Personal";
            return View(historial);        
        }

		#endregion


    }
}

